import type { PtPageJson } from "@/modules/pt-page/types";
import { requestJson } from "@/utils/request";
import { getShaderConfig } from "./version1";

interface PublicParams {
    // 公开查看
    dataToken: string;
}

interface StudentParams {
    // 登录查看
    userId: string;
    name: string;
    token: string;
    udid: string;
}

export type OriginData = PublicParams | StudentParams;

export const getBookletShader = (createdId: string, params: PublicParams): Promise<PtPageJson> => {
    return requestJson({
        url: '/eduGrowth/preview/getManualDetail',
        method: 'POST',
        data: {
            id: createdId,
            pw: params.dataToken
        }
    })
        .then(result => result.data)
        .then(data => {
            return getShaderConfig(data);
        });
}

export const getBookletShaderFromStudent = (createdId: string, params: StudentParams): Promise<PtPageJson> => {
    return requestJson({
        url: '/eduGrowth/api/parent/getManualDetail',
        method: 'POST',
        data: {
            token: params.token,
            udid: params.udid,
            version: 3,
            id: createdId
        }
    })
        .then(result => result.data)
        .then(data => {
            return getShaderConfig(data);
        });
}